package mil.af.amc.adpetracker.model;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */

@Entity
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name="T_EQUIPMENTTYPE")
public class EquipmentType implements Serializable, Comparable<EquipmentType>, MappableEntity {

    private int id;
    private String name;

    @Id
    @Column(name="TYPEID")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "SEQ_EQUIPMENT")
    @SequenceGenerator(name="SEQ_EQUIPMENT", sequenceName = "S_EQUIPMENT")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name="DESCRIPTION")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int compareTo(EquipmentType o) {

        return this.getName().trim().toUpperCase().compareTo(o.getName().trim().toUpperCase());

    }

    public Map toMap() {

        Map results = new HashMap();
        results.put("id", this.getId());
        results.put("name", this.getName());

        return results;
    }
}
